package com.ruoyi.wb.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.wb.domain.WbClassify;
import com.ruoyi.wb.domain.WbClassifyContent;
import com.ruoyi.wb.mapper.WbClassifyMapper;
import com.ruoyi.wb.service.IWbClassifyContentService;
import com.ruoyi.wb.service.IWbClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 维保类目列Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-10-14
 */
@Service
public class WbClassifyServiceImpl implements IWbClassifyService 
{
    @Autowired
    private WbClassifyMapper wbClassifyMapper;

    @Autowired
    private IWbClassifyContentService wbClassifyContentService;

    /**
     * 查询维保类目列
     * 
     * @param id 维保类目列主键
     * @return 维保类目列
     */
    @Override
    public WbClassify selectWbClassifyById(Long id)
    {
        return wbClassifyMapper.selectWbClassifyById(id);
    }

    /**
     * 查询维保类目列列表
     * 
     * @param wbClassify 维保类目列
     * @return 维保类目列
     */
    @Override
    public List<WbClassify> selectWbClassifyList(WbClassify wbClassify)
    {
        List<WbClassify> lists=wbClassifyMapper.selectWbClassifyList(wbClassify);
        for(WbClassify wbClassify1:lists){
            ///////////////////////
            WbClassifyContent wbClassifyContent=new WbClassifyContent();
            wbClassifyContent.setClassifyId(wbClassify1.getId());
            List<WbClassifyContent>  wbClassifyContents= wbClassifyContentService.selectWbClassifyContentList(wbClassifyContent);
            wbClassify1.setWbClassifyContents(wbClassifyContents);
        }
        return lists;
    }

    /**
     * 新增维保类目列
     * 
     * @param wbClassify 维保类目列
     * @return 结果
     */
    @Override
    public int insertWbClassify(WbClassify wbClassify)
    {
        wbClassify.setCreateTime(DateUtils.getNowDate());
        wbClassify.setTier(1L);
        return wbClassifyMapper.insertWbClassify(wbClassify);
    }

    /**
     * 修改维保类目列
     * 
     * @param wbClassify 维保类目列
     * @return 结果
     */
    @Override
    public int updateWbClassify(WbClassify wbClassify)
    {
        wbClassify.setUpdateTime(DateUtils.getNowDate());
        return wbClassifyMapper.updateWbClassify(wbClassify);
    }

    /**
     * 批量删除维保类目列
     * 
     * @param ids 需要删除的维保类目列主键
     * @return 结果
     */
    @Override
    public int deleteWbClassifyByIds(Long[] ids)
    {
        return wbClassifyMapper.deleteWbClassifyByIds(ids);
    }

    /**
     * 删除维保类目列信息
     * 
     * @param id 维保类目列主键
     * @return 结果
     */
    @Override
    public int deleteWbClassifyById(Long id)
    {
        return wbClassifyMapper.deleteWbClassifyById(id);
    }
}
